package com.ehotting.mqbd.zw.api.bean;

import com.ehotting.mqbd.api.bean.MQBaseData;
import com.ehotting.mqbd.api.bean.MqApplicationContext;
import com.ehotting.mqbd.api.enums.ProtocolTypeEnum;
import com.ehotting.mqbd.api.enums.TopicEnum;
import com.ehotting.mqbd.zw.api.domain.netty.ZwCommPacket;
import org.springframework.util.Assert;

public class ZwMQTcpData extends MQBaseData<ZwCommPacket,ZwCommPacket> {


    private ZwCommPacket request;
    private ZwCommPacket response;

    public ZwMQTcpData() {
        super();
        this.setProtocolType(ProtocolTypeEnum.TCP);
        this.syncExecute = false;
    }

    public ZwMQTcpData(TopicEnum topic, String consumerHost, String localHost, String agentId, String module, String msg) {
        super( topic, consumerHost,  localHost,  agentId,  module,  msg);
        this.setProtocolType(ProtocolTypeEnum.TCP);
        this.syncExecute = false;
    }


    public static ZwMQTcpData create(TopicEnum topic, String consumerHost, String localHost, String agentId, String module, String msg){
        Assert.notNull(topic,"topic is null");
        return new ZwMQTcpData( topic, consumerHost,  localHost,  agentId,  module,  msg);
    }

    public static ZwMQTcpData create(TopicEnum topic, MqApplicationContext mqApplicationContext, String agentId, String msg) {
        Assert.notNull(topic, "topic is null");
        return new ZwMQTcpData(topic,
                mqApplicationContext.getConsumerHost(),
                mqApplicationContext.getLocalHost(),
                agentId,
                mqApplicationContext.getModule(),
                msg);
    }

    @Override
    public ZwCommPacket getRequest() {
        return request;
    }

    @Override
    public void setRequest(ZwCommPacket request) {
        this.request = request;
    }

    @Override
    public ZwCommPacket getResponse() {
        return response;
    }


    @Override
    public void setResponse(ZwCommPacket response) {
        this.response = response;
    }


}
